﻿@model DriveBabyDrive.Models.ReadingModel
@{
    ViewBag.Title = "Take Reading";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        //code to get location
        //Make sure that the browser supports geolocation
        if (navigator.geolocation != undefined) {

            var latti = navigator.geolocation.getCurrentPosition(function (pos) {
                var latti = pos.coords.latitude;
                var longi = pos.coords.longitude;
                //alert(latti, longi);
                $("#txtLatitude").val(latti);
                $("#txtLongitude").val(longi);
            });
        }
        else {
            //if geolocation is not supported or permission to store location is not given then don't store the location
            //alert('geoLoc not supported');
            $("#txtLatitude").val(0);
            $("#txtLongitude").val(0);
        }

    });
</script>
@section Header {
<div class="ui-grid-b" style="padding:1%">
	    <div class="ui-block-a">@Html.ActionLink("Back", "Index/", "Home", null, new { data_icon = "arrow-l", data_role="button"})</div>
	    <div class="ui-block-b"  style="text-align:center">@Html.ActionLink("Home", "Index/", "Home", null, new { data_icon = "home", data_iconpos="notext", data_role="button"})</div>
	    <div class="ui-block-c" style="text-align:right"> @Html.Partial("_LogOnPartial")</div>
    </div>
}


@using (Html.BeginForm()) {
    @Html.ValidationSummary(true, "Reading could not be saved. Please correct the errors and try again.")

    <ul data-role="listview" data-inset="true">
        <li data-role="list-divider">Reading</li>
        <li data-role="fieldcontain">
           
                @Html.DropDownListFor(m => m.UserVehicleID, ViewData["UserVehicles"] as SelectList, new { @type = "text" }) 
                @Html.ValidationMessageFor(m => m.UserVehicleID)
        </li>
        <li data-role="fieldcontain">            

            @Html.LabelFor(m => m.Odometer)
            @Html.TextBoxFor(m => m.Odometer, new { @type = "number", @placeholder = "Odometer" })
            @Html.ValidationMessageFor(m => m.Odometer)
        </li>

        <li data-role="fieldcontain">
            @Html.LabelFor(m => m.FuelPrice)
            @Html.TextBoxFor(m => m.FuelPrice, new { @type = "number", @placeholder = "Gas Price per Gallon", @step = "any", @min = "0" })
            @Html.ValidationMessageFor(m => m.FuelPrice)
        </li>

        <li data-role="fieldcontain">
            @Html.LabelFor(m => m.FuelAdded)
            @Html.TextBoxFor(m => m.FuelAdded, new { @type = "number", @placeholder = "Gallons Filled", @step = "any", @min = "0" })
            @Html.ValidationMessageFor(m => m.FuelAdded)
        </li>
        <li data-role="fieldcontain" style="display:none" >
            
            @Html.TextBoxFor(m => m.Lattitude, new { @id = "txtLatitude", @step = "any" })
            
        </li>

        <li data-role="fieldcontain" style="display:none">
            
            @Html.TextBoxFor(m => m.Longitude, new { @id = "txtLongitude",  @step = "any" })
            
        </li>

   

        <li data-role="fieldcontain">
            <input type="submit" value="Save"  />
        </li>
    </ul>
}